<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRefundsTable extends Migration
{

    protected $tableName = 'refunds';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->increments('id');
            $table->string('refund_no')->unique()->comment('退款单号');
            $table->unsignedInteger('order_id')->comment('订单ID');
            $table->decimal('refund_amount')->comment('退款价钱');
            $table->unsignedTinyInteger('status')->comment('订单状态');
            $table->string('remark')->nullable()->comment('备注');

            $table->timestamps();
            $table->softDeletes();

            $table->index('order_id');
        });
        DB::statement("ALTER TABLE `$this->tableName` comment '退款表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
}
